#lang racket


(require "../base/main.rkt")

(require "domain.rkt"
         "curve.rkt"
         "parametric.rkt")

(provide (struct-out straight-curve)
         straight-curve-object
         straight-curve-tangent
         straight-curve-normal
         straight-curve-binormal
         make-straight-curve)


(define-struct (straight-curve curve)
  (start end)
  #:constructor-name new-straight-curve)


(define (straight-curve-object start end)
  (λ (t)
    (add-c
     (mult-c start (- 1 t))
     (mult-c end t))))

(define (straight-curve-tangent start end)
  (λ (t)
    (norm (sub-c end start))))

(define (straight-curve-normal start end)
  (λ (t)
    (raise unsupported "The normal is not defined for a straight line")))

(define (straight-curve-binormal start end)
  (λ (t)
    (raise unsupported "The binormal is not defined for a straight line")))

(define (make-straight-curve start end)
  (new-straight-curve
   (straight-curve-object start end)
   (straight-curve-tangent start end)
   (straight-curve-normal start end)
   (straight-curve-binormal start end)
   (make-t-domain 'closed 0 'closed 1)
   start
   end))